import pandas as pd
from pyecharts import options as opts
from pyecharts.charts import Map
data = pd.read_csv('final_jobinfo.csv')
# 将类似深圳-罗湖区的数据以 - 切分为两列
data[['地区','区']] = data['地区'].str.split('-',expand=True)

# 按地区进行分组统计，统计每个区招聘岗位的数量
data = data['地区'].groupby(data['区']).value_counts()
areas = []
values = []

for key,value in zip(data.keys(),data.values):
    # 去除深圳地区以外的招聘信息
    if key[1] == '深圳':
        area = key[0].strip()
        if "龙华" in key[0]:
            area = '龙华区'
        areas.append(area)
        values.append(int(value))

map = Map()
map.add("招聘人数", [list(z) for z in zip(areas, values)], "深圳")
map.set_global_opts(title_opts=opts.TitleOpts(title="深圳大数据岗位分布数量图"),
visualmap_opts=opts.VisualMapOpts(max_=800, range_color=["lightskyblue", "yellow", "orangered"],is_piecewise=True),tooltip_opts=opts.TooltipOpts(is_show=True))
map.render(path = '深圳岗位分布数量图.html')